

using System;
using System.Collections.Generic;
using System.Text;
using EntityLayer;
using System.Data;
using DataAccessLayer;
using InfraStructureLayer;

namespace DataLayer
{
	public class datFiles
	{
		public datFiles()
		{
		}
		
		#region  Code Factory Generated Methods
        public void DeleteFilesByFileId(entFiles parEntFiles, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pFileId", parEntFiles.FileId);
            parDbConnector.ExecuteNonQuery("DeleteFilesByFileId", insDbParamCollection);
        }
        public void InsertFiles(entFiles parEntFiles, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pFileDescription", parEntFiles.FileDescription);
            insDbParamCollection.Add("@pInsertDate", parEntFiles.InsertDate);
            insDbParamCollection.AddOutput("@pFileId", DbType.Int32);
            parDbConnector.ExecuteNonQuery("InsertFiles", insDbParamCollection);
            parEntFiles.FileId = Convert.ToInt32(insDbParamCollection.GetOutPutParameter().Value);
        }
        public void UpdateFilesByFileId(entFiles parEntFiles, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pFileId", parEntFiles.FileId);
            insDbParamCollection.Add("@pInsertDate", parEntFiles.InsertDate);
            insDbParamCollection.Add("@pFileDescription", parEntFiles.FileDescription);
            parDbConnector.ExecuteNonQuery("UpdateFilesByFileId", insDbParamCollection);
        }
        public DataTable SelectFiles(DbConnector parDbConnector)
        {

            return parDbConnector.ExecuteDataTable("SelectFiles", null);
        }
        public void SelectFilesByFileId(entFiles parEntFiles, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pFileId", parEntFiles.FileId);
            DataTable insDataTable = new DataTable();
            insDataTable = parDbConnector.ExecuteDataTable("SelectFilesByFileId", insDbParamCollection);
            if (insDataTable.Rows.Count > 0)
            {
                if (insDataTable.Rows[0]["FileId"] != DBNull.Value)
                {
                    parEntFiles.FileId = Convert.ToInt32(insDataTable.Rows[0]["FileId"]);
                }
                if (insDataTable.Rows[0]["FileDescription"] != DBNull.Value)
                {
                    parEntFiles.FileDescription = insDataTable.Rows[0]["FileDescription"].ToString();
                }
                if (insDataTable.Rows[0]["InsertDate"] != DBNull.Value)
                {
                    parEntFiles.InsertDate = Convert.ToDateTime(insDataTable.Rows[0]["InsertDate"]);
                }
            }
        }
		#endregion
        public DataTable SelectFilesLatest(DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pLanguageId", CurrentContext.LanguageId);
            return parDbConnector.ExecuteDataTable("SelectFilesLatest", insDbParamCollection);
        }
        public DataTable SelectFilesByLanguageId(DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pLanguageId", CurrentContext.LanguageId);
            return parDbConnector.ExecuteDataTable("SelectFilesByLanguageId", insDbParamCollection);
        }
	}
}